package org.tinygroup.weblayerdemo;

import org.tinygroup.logger.LogLevel;
import org.tinygroup.weblayer.AbstractTinyProcessor;
import org.tinygroup.weblayer.WebContext;

import javax.servlet.ServletException;
import java.io.IOException;

/**
 * Created by wangwy11342 on 2015/12/30.
 */
public class SimpleActionProcessor extends AbstractTinyProcessor {

    @Override
    protected void customInit() throws ServletException {

    }

    @Override
    public void reallyProcess(String s, WebContext webContext)
            throws ServletException, IOException {
        logger.logMessage(LogLevel.INFO,"=======Hello,Processor======");
        String forwardPage = "/error.html";
        if(s.startsWith("/login.")){
            forwardPage = "/login.html";
        }else if(s.startsWith("/main.")){
            forwardPage = "/main.html";
        }
        webContext.getRequest().getRequestDispatcher(forwardPage)
                .forward(webContext.getRequest(),webContext.getResponse());
    }
}
